package spindles.api.db;

import java.math.BigDecimal;
import java.math.BigInteger;

import com.sleepycat.persist.model.Persistent;
import com.sleepycat.persist.model.PersistentProxy;

@Persistent(proxyFor=BigDecimal.class)
public class BigDecimalProxy implements PersistentProxy<BigDecimal>{
	
	private BigInteger intVal;	
	private int scale = 0;	
	
	public BigDecimal convertProxy() {		
		return new BigDecimal(intVal, scale);
	}

	public void initializeProxy(BigDecimal number) {		
		scale = number.scale();
		intVal = number.unscaledValue();
	}

}
